package com.scuec.groupfive.Controller;

import com.scuec.groupfive.service.PostLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import java.util.Date;

@RestController
@RequestMapping("/post-like")
@CrossOrigin
public class PostLikeController {
    @Autowired
    private PostLikeService postLikeService;

    @GetMapping("/total-count")
    public int getTotalLikeCount() {
        return postLikeService.getTotalLikeCount();
    }

    @GetMapping("/count-by-date")
    public int getLikeCountByDateRange(
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
        return postLikeService.getLikeCountByDateRange(startDate, endDate);
    }
}